from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import BookViewSet

router = DefaultRouter()
router.register(r'books', BookViewSet)

urlpatterns = [
    path('', include(router.urls)),
]

# 添加自定义操作的URL模式
urlpatterns += [
    path('books/<int:pk>/borrow/', BookViewSet.as_view({'post': 'borrow'}), name='book-borrow'),
    path('books/<int:pk>/return/', BookViewSet.as_view({'post': 'return_book'}), name='book-return'),
]
